import { View } from "../../../../mvc/core/View";
import { LayerManager } from "../../../manager/LayerManager";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { Global } from "../../../../../com/gengine/global/Global";
import { SceneRange } from "../../../scene/map/SceneRange";
import { SCopyEightyDefenceInfo } from "../../../../../Message/Public/SCopyEightyDefenceInfo";
import { SCopyMsgInfo } from "../../../../../Message/Public/SCopyMsgInfo";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class EightyDefenceCopyView
    
    export  class EightyDefenceCopyView extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._bg = ObjCreate.createGImageBitmap(ImagesConst.eightyDefenceBg, 0, 0, this);
            this._smallBgBmp = ObjCreate.createBitmap(null, 3, 30, this);
            this._statusBmp = ObjCreate.createBitmap(null, 5, -35, this);
            this._expBmp = ObjCreate.createBitmap(null, 50, 102, this);
            this._scoreBmp = ObjCreate.createBitmap(null, 50, 137, this);
            this._lineBmp = ObjCreate.createBitmap(null, 5, 130, this);
            LoaderHelp.addResCallBack(ResFileConst.EightyDefenceCopy, this.onResLoaded);
            ObjCreate.createGTextField(Language.getString(60474), 85, 35, 150, 20, this, GlobalStyle.textFormat6);
            var loc1=ObjCreate.createBitmap(ImagesConst.RedProgressBar, 85, 62, this);
            loc1.width = 164;
            this._redProgress = ObjCreate.createBitmap(ImagesConst.RedProgress, 85, 62, this);
            this._progressTxt = ObjCreate.createGTextField("100/100", 85, 60, 164, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat6));
            this._ringInfoTxt = ObjCreate.createGTextField("", 0, 4, 268, 22, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat6));
            this._ringInfoTxt.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMoveMouseDown);
            var loc2=GlobalStyle.textFormat2;
            loc2.size = 16;
            this._expTxt = ObjCreate.createGTextField("0", 145, 102, 150, 20, this, loc2);
            var loc3=GlobalStyle.textFormat5;
            loc3.size = 16;
            this._scoreTxt = ObjCreate.createGTextField("0", 145, 137, 150, 20, this, loc3);
            this._supBtn = ObjCreate.createGButton("", 235, 2, 24, 22, this, "MoveBtn");
            this._supBtn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMoveMouseDown);
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._statusBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.eightyDefenceStatue);
            this._smallBgBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.eightyDefenceSmallBg);
            this._expBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.eightyDefenceExp);
            this._scoreBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.eightyDefenceScore);
            this._lineBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.eightyDefenceLine);
            return;
        }

        /* internal  */onMoveMouseDown(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (arg1.target == this._ringInfoTxt || arg1.target == this._supBtn) 
            {
                this.startDrag();
                Global.stage.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onStageMouseUpHandler);
            }
            return;
        }

        /* internal  */onStageMouseUpHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.stopDrag();
            Global.stage.removeEventListener(flash.events.MouseEvent.MOUSE_UP, this.onStageMouseUpHandler);
            return;
        }

        public stageResize(): void
        {
            this.x = SceneRange.display.width - 278;
            this.y = 220;
            return;
        }

        public updateEightyDefenceInfo(arg1: SCopyEightyDefenceInfo): void
        {
            if (arg1 == null) 
            {
                return;
            }
            this._scoreTxt.htmlText = "<font color=\'#60e71e\'>" + arg1.score + "</font>";
            if (arg1.currentLife > 0) 
            {
                this._redProgress.width = 164 * arg1.currentLife / arg1.maxLife;
                this._progressTxt.htmlText = "<font color=\'#f0ea3f\'>" + arg1.currentLife + "/" + arg1.maxLife + "</font>";
            }
            else 
            {
                this._redProgress.width = 0;
                this._progressTxt.htmlText = "0/" + arg1.maxLife;
            }
            return;
        }

        public updateExp(arg1: int): void
        {
            this._expTxt.htmlText = "<font color=\'#F1FFB1\'>" + arg1 + "</font>";
            return;
        }

        public updateRing(arg1: SCopyMsgInfo): void
        {
            if (arg1 == null) 
            {
                return;
            }
            this._ring = arg1.num1;
            var loc1=Math.floor((this._ring + 5) / 6);
            this._ringInfoTxt.text = Language.getStringByParam(60471, loc1);
            if (this._ring != 1) 
            {
                if (this._ring == 475) 
                {
                    this._ringInfoTxt.text = Language.getString(60473);
                }
            }
            else 
            {
                this._ringInfoTxt.text = Language.getString(60472);
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            this.stageResize();
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this._expTxt.htmlText = "<font color=\'#F1FFB1\'>0</font>";
            this._scoreTxt.htmlText = "<font color=\'#60e71e\'>0</font>";
            this._progressTxt.htmlText = "<font color=\'#f0ea3f\'>100/100</font>";
            this._redProgress.width = 164;
            this._ringInfoTxt.htmlText = "";
            return;
        }

        /* internal */ /* var */_bg: GImageBitmap;

        /* internal */ /* var */_statusBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_smallBgBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_expBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_scoreBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_lineBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_ringInfoTxt: GTextFiled;

        /* internal */ /* var */_expTxt: GTextFiled;

        /* internal */ /* var */_scoreTxt: GTextFiled;

        /* internal */ /* var */_supBtn: GButton;

        /* internal */ /* var */_redProgress: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_progressTxt: GTextFiled;

        /* internal */ /* var */_ring: int;
    }
